﻿namespace TomatoBreak.Infrastructure
{
    using System;
    using System.Web.Mvc;
    using System.Web.Routing;

    using Combres;

    using Web;

    public class RoutesRegistrar : IRegistrar
    {
        private readonly RouteCollection routes;

        public RoutesRegistrar(RouteCollection routes)
        {
            if (routes == null)
            {
                throw new ArgumentNullException("routes");
            }

            this.routes = routes;
        }

        public virtual void Register()
        {
            routes.AddCombresRoute("combres");

            routes.Resources<TasksController>()
                  .Resource<UserController>()
                  .Resource<SessionController>();

            routes.MapRoute("default", "{controller}/{action}/{id}", new { controller = "home", action = "index", id = UrlParameter.Optional });
        }
    }
}